<?php
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
$mc= new libstr();

class shuxing{
	
	//获得单个属性类别列表
function getshuxinglist($tb){
	global $db;
	$getrs=array();
	if($tb!=""){
		$getrs=$db->ds("select * from ".$tb." order by classorder asc");
	}
	return $getrs;
}
//获得单个属性详细
function getshuxingshow($tb,$id){
	global $db;
	$getrs=array();
	if($tb!=""){
		$getrs=$db->ds("select * from ".$tb." where ID=".$id);
	}
	return $getrs[0];
}
//删除一单个属性类别
function deleteshuxing($tb,$id){
	global $db;
	if($tb!=""&& $id!=""){
	$db->cmd("delete from ".$tb." where ID =".$id);
		return true;
	}
	return false;
}
//删除多个属性
 function deleteshuxings($tb,$idarr){
 	global $db;
 	if($tb!=""){
 		for($i=0;$i<count($idarr);$i++){
	$db->cmd("delete from ".$tb." where ID =".$idarr[$i]);
		
	}
	return true;
 	}
 	return false;
 }
 //增加一个属性  $arr代表添加的数组资料如array("classname"=>"普通会员","quanxian"=>1)
 function addshuxing($tb,$classname,$content="",$classorder=0){
 	global $db;
 if($tb!=""){
 	$db->cmd("insert into ".$tb."(classname,content,classorder)values('".trim($classname)."','".trim($content)."','".$classorder."')");
 	$lastid=$db->insert_id();
 	$rootid="0,".$lastid.",";
 	$db->cmd("update ".$tb." set rootid='".$rootid."' where id=".$lastid);
 	return true;
 	}
 	return false;
 }
 
//更新一个属性 
function updateshuxing($tb,$id,$classname,$content="",$classorder=0){
		global $db;
 if($tb!=""){
 
 	$db->cmd("update ".$tb." set classname='".$classname."', content='".$content."', classorder='".$classorder."' where ID=".$id);
 	return true;
 }
 return false;
}

//获得全部属性种类
function getshuxingtype($isshow=1){
	global $db;
	$tp=$db->ds("select * from shuxing_type where isshow>=".$isshow." order by classorder");
	return $tp;
}
//获得属性类别名称
function getshuxingclassname($ziduan){
	global $db;
	$sx=$db->ds("select * from shuxing_type where isshow>0 and ziduan='".$ziduan."'");
	return $sx[0]["classname"];
	
}
//获得属性类别详细
function getshuxintypegshow($id){
	global $db;
	$sx=$db->dvstr("select * from shuxing_type where id=".$id);
	return $sx;
	
}

}

?>